import request from '@/utils/request'

// 获取任务列表
export function getTaskList(params) {
  return request({
    url: '/task/list',
    method: 'get',
    params
  })
}

// 获取任务详情
export function getTaskDetail(taskId) {
  return request({
    url: '/task/detail',
    method: 'get',
    params: { taskId }
  })
}

// 发布任务
export function publishTask(data) {
  return request({
    url: '/task/publish',
    method: 'post',
    data
  })
}

// 接受任务
export function takeTask(taskId) {
  return request({
    url: '/task/take',
    method: 'post',
    data: { taskId }
  })
}

// 完成任务
export function completeTask(taskId) {
  return request({
    url: '/task/complete',
    method: 'post',
    data: { taskId }
  })
}

// 取消任务
export function cancelTask(taskId, reason) {
  return request({
    url: '/task/cancel',
    method: 'post',
    data: { taskId, reason }
  })
}